package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.danmo.domain.DanmoGalleryWorkMaterial;
import com.muyu.danmo.service.IDanmoGalleryWorkMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 作品材质Controller
 *
 * @author yangle
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/galleryWorkMaterial")
public class DanmoGalleryWorkMaterialController extends BaseController
{
    @Autowired
    private IDanmoGalleryWorkMaterialService danmoGalleryWorkMaterialService;

    /**
     * 查询作品材质列表
     */
//    @RequiresPermissions("system:galleryWorkMaterial:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoGalleryWorkMaterial>> list(DanmoGalleryWorkMaterial danmoGalleryWorkMaterial)
    {
        startPage();
        List<DanmoGalleryWorkMaterial> list = danmoGalleryWorkMaterialService.selectDanmoGalleryWorkMaterialList(danmoGalleryWorkMaterial);
        return getDataTable(list);
    }

    /**
     * 导出作品材质列表
     */
//    @RequiresPermissions("system:galleryWorkMaterial:export")
    @Log(title = "作品材质", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoGalleryWorkMaterial danmoGalleryWorkMaterial)
    {
        List<DanmoGalleryWorkMaterial> list = danmoGalleryWorkMaterialService.selectDanmoGalleryWorkMaterialList(danmoGalleryWorkMaterial);
        ExcelUtil<DanmoGalleryWorkMaterial> util = new ExcelUtil<DanmoGalleryWorkMaterial>(DanmoGalleryWorkMaterial.class);
        util.exportExcel(response, list, "作品材质数据");
    }

    /**
     * 获取作品材质详细信息
     */
//    @RequiresPermissions("system:galleryWorkMaterial:query")
    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return success(danmoGalleryWorkMaterialService.selectDanmoGalleryWorkMaterialById(id));
    }

    /**
     * 新增作品材质
     */
//    @RequiresPermissions("system:galleryWorkMaterial:add")
    @Log(title = "作品材质", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoGalleryWorkMaterial danmoGalleryWorkMaterial)
    {
        return toAjax(danmoGalleryWorkMaterialService.insertDanmoGalleryWorkMaterial(danmoGalleryWorkMaterial));
    }

    /**
     * 修改作品材质
     */
//    @RequiresPermissions("system:galleryWorkMaterial:edit")
    @Log(title = "作品材质", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoGalleryWorkMaterial danmoGalleryWorkMaterial)
    {
        return toAjax(danmoGalleryWorkMaterialService.updateDanmoGalleryWorkMaterial(danmoGalleryWorkMaterial));
    }

    /**
     * 删除作品材质
     */
//    @RequiresPermissions("system:galleryWorkMaterial:remove")
    @Log(title = "作品材质", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        return toAjax(danmoGalleryWorkMaterialService.deleteDanmoGalleryWorkMaterialByIds(ids));
    }
}
